{% extends '::layout.html.twig' %}

{% block title %}Ecrire une lettre{% endblock %}

{% block js %}
    <script type="text/javascript" src="{{ asset('bundles/lettralletter/js/jquery.letter.list.js') }}"></script>
{% endblock %}

{% block content %}

<div class="list">
	<br />
	<div id="toolbar">
		<div class="button" id="multipleDeletes">
			<a class="button" id="multipleDeletes" href="{{ path('letter_letter_multiple_deletes') }}">Supprimer la sélection</a>
		</div>
		<div id="filter">Filtrer : </div>
		<div class="button" id="archived">
			<a class="button" id="archived">Archivé</a>
		</div>
		<div class="button" id="draft">
			<a class="button" id="draft">Brouillon</a>
		</div>
		<div class="button" id="previous" {% if hasPrev == 1 %} style="visibility: hidden;" {% endif %}>
			<a class="button" id="previous" href="{{ path('letter_letter_list') }}">Précédent</a>
		</div>
		<div class="button" id="next" {% if hasNext == 1 %} style="visibility: hidden;" {% endif %}>
			<a class="button" id="next" href="{{ path('letter_letter_list') }}">Suivant</a>
		</div>
	</div>
	<table>
		<tr>
			<th class="top"><input type="checkbox" id="all" /></th>
			<th class="top">Destinataire</th>
			<th class="top">Objet</th>
			<th class="top" id="date">Modifié le</th>
			<th class="top">Etat</th>
			<th class='actions'>Actions</th>
		</tr>
		{% for letter in letters %}
		<tr id="{{ letter.numLettre }}">
			<td>
				<input type="checkbox" name="id" id="{{ letter.numLettre }}" />
			</td>
			<td>
				{{ letter.nomDest }}
				{% if letter.compNomDest1 != null %}
					- {{ letter.compNomDest1 }}
				{% endif %}	
			</td>
			<td>{{ letter.sujet }}</td>
			<td>{{ letter.dateDerModif|date("d/m/Y") }}</td>
			<td>
				{% if letter.statut == 1 %}
					Brouillon
				{% elseif letter.statut == 2 %}
					Archivé
				{% elseif letter.statut == 3 %}
					Erreur
				{% else %}
					Erreur
				{% endif %}
			</td>
			<td class='actions'>
				{% if letter.statut == 2 %}
					<a class="download" href="{{ path('letter_letter_download', { 'numLettre': letter.numLettre }) }}" title="Télécharger en PDF"><img src="{{ asset('bundles/lettralletter/images/download.png') }}" ></a>
				{% endif %}
                &nbsp;&nbsp;<a class="action" href="{{ path('letter_letter_edit', { 'numLetter': letter.numLettre }) }}" title="Modifier"><img src="{{ asset('bundles/lettralletter/images/edit.png') }}" ></a>
                &nbsp;&nbsp;<a class="delete" href="{{ path('letter_letter_delete', { 'numLetter': letter.numLettre }) }}" title="Supprimer"><img src="{{ asset('bundles/lettralletter/images/delete.png') }}" ></a>
            </td>
		</tr>
		{% else %}
		<tr><td colspan='5'>Vous n'avez aucune lettre pour l'instant !</td></tr>
		{% endfor %}		
	</table>
</div>

{% endblock %}
